#ifndef GATE_MODULE_H
#define GATE_MODULE_H

#include "net_module.h"
#include <list>
namespace utility
{
namespace network
{
    class gate_listener : public utility::base
    {
    public:
        // initialize
        virtual bool initialize(session_mgr *) = 0;

        // begin to listen specify TCP port
        virtual bool start(const char * ip_address, const char * port) = 0;

        virtual void set_max_recv_buf_size(uint32 size) = 0;

        virtual void broadcast(std::list<session *> sessions, void * message, size_t message_length) = 0;
    };

    class gate_connector : public utility::base
    {
    public:
        // initialize
        virtual bool initialize(session_mgr *) = 0;

        // connect to gate listener before establishing the connection between client and server
        virtual bool connect_listener(const char * ip_address, const char * port) = 0;

        // establish the connection between client and server
        virtual bool connect(uint32 client_ip, uint16 client_port) = 0;
    };

    class gate_module : public utility::base
    {
    public:
        // initialize
        virtual bool initialize(net_module * ) = 0;

        // create the gate listener
        virtual gate_listener * create_listener() = 0;

        // create the connector
        virtual gate_connector * create_connector() = 0;
    };
}   // namespace of network
}   // namespace of utility

utility::network::gate_module * get_gate_module();
void destroy_gate_module();

#endif // endif of GATE_MODULE_H
